package cn.edu.scau.cmi.hombio.web.rest;

import cn.edu.scau.cmi.hombio.dao.CurePigDAO;
import cn.edu.scau.cmi.hombio.dao.PigDAO;
import cn.edu.scau.cmi.hombio.dao.PigTypeDAO;
import cn.edu.scau.cmi.hombio.dao.PigWeightDAO;
import cn.edu.scau.cmi.hombio.dao.SalePigDAO;
import cn.edu.scau.cmi.hombio.dao.TaskPigDAO;
import cn.edu.scau.cmi.hombio.dao.TransferDAO;

import cn.edu.scau.cmi.hombio.domain.CurePig;
import cn.edu.scau.cmi.hombio.domain.Pig;
import cn.edu.scau.cmi.hombio.domain.PigType;
import cn.edu.scau.cmi.hombio.domain.PigWeight;
import cn.edu.scau.cmi.hombio.domain.SalePig;
import cn.edu.scau.cmi.hombio.domain.TaskPig;
import cn.edu.scau.cmi.hombio.domain.Transfer;

import cn.edu.scau.cmi.hombio.service.PigService;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.stereotype.Controller;

import org.springframework.web.bind.WebDataBinder;

import org.springframework.web.bind.annotation.InitBinder;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Spring Rest controller that handles CRUD requests for Pig entities
 * 
 */

@Controller("PigRestController")

public class PigRestController {

	/**
	 * DAO injected by Spring that manages CurePig entities
	 * 
	 */
	@Autowired
	private CurePigDAO curePigDAO;

	/**
	 * DAO injected by Spring that manages Pig entities
	 * 
	 */
	@Autowired
	private PigDAO pigDAO;

	/**
	 * DAO injected by Spring that manages PigType entities
	 * 
	 */
	@Autowired
	private PigTypeDAO pigTypeDAO;

	/**
	 * DAO injected by Spring that manages PigWeight entities
	 * 
	 */
	@Autowired
	private PigWeightDAO pigWeightDAO;

	/**
	 * DAO injected by Spring that manages SalePig entities
	 * 
	 */
	@Autowired
	private SalePigDAO salePigDAO;

	/**
	 * DAO injected by Spring that manages TaskPig entities
	 * 
	 */
	@Autowired
	private TaskPigDAO taskPigDAO;

	/**
	 * DAO injected by Spring that manages Transfer entities
	 * 
	 */
	@Autowired
	private TransferDAO transferDAO;

	/**
	 * Service injected by Spring that provides CRUD operations for Pig entities
	 * 
	 */
	@Autowired
	private PigService pigService;

	/**
	 * Delete an existing CurePig entity
	 * 
	 */
	@RequestMapping(value = "/Pig/{pig_id}/curePigs/{curepig_id}", method = RequestMethod.DELETE)
	@ResponseBody
	public void deletePigCurePigs(@PathVariable Integer pig_id, @PathVariable Integer related_curepigs_id) {
		pigService.deletePigCurePigs(pig_id, related_curepigs_id);
	}

	/**
	* Show all Pig entities by Pig
	* 
	*/
	@RequestMapping(value = "/Pig/{pig_id}/pigsForMostLikelyMaleParentId", method = RequestMethod.GET)
	@ResponseBody
	public List<Pig> getPigPigsForMostLikelyMaleParentId(@PathVariable Integer pig_id) {
		return new java.util.ArrayList<Pig>(pigDAO.findPigByPrimaryKey(pig_id).getPigsForMostLikelyMaleParentId());
	}

	/**
	* Create a new CurePig entity
	* 
	*/
	@RequestMapping(value = "/Pig/{pig_id}/curePigs", method = RequestMethod.POST)
	@ResponseBody
	public CurePig newPigCurePigs(@PathVariable Integer pig_id, @RequestBody CurePig curepig) {
		pigService.savePigCurePigs(pig_id, curepig);
		return curePigDAO.findCurePigByPrimaryKey(curepig.getId());
	}

	/**
	* Delete an existing Transfer entity
	* 
	*/
	@RequestMapping(value = "/Pig/{pig_id}/transfers/{transfer_id}", method = RequestMethod.DELETE)
	@ResponseBody
	public void deletePigTransfers(@PathVariable Integer pig_id, @PathVariable Integer related_transfers_id) {
		pigService.deletePigTransfers(pig_id, related_transfers_id);
	}

	/**
	* Create a new Pig entity
	* 
	*/
	@RequestMapping(value = "/Pig/{pig_id}/pigsForMostLikelyMaleParentId", method = RequestMethod.POST)
	@ResponseBody
	public Pig newPigPigsForMostLikelyMaleParentId(@PathVariable Integer pig_id, @RequestBody Pig pig) {
		pigService.savePigPigsForMostLikelyMaleParentId(pig_id, pig);
		return pigDAO.findPigByPrimaryKey(pig.getId());
	}

	/**
	* Delete an existing PigWeight entity
	* 
	*/
	@RequestMapping(value = "/Pig/{pig_id}/pigWeights/{pigweight_id}", method = RequestMethod.DELETE)
	@ResponseBody
	public void deletePigPigWeights(@PathVariable Integer pig_id, @PathVariable Integer related_pigweights_id) {
		pigService.deletePigPigWeights(pig_id, related_pigweights_id);
	}

	/**
	* Save an existing Pig entity
	* 
	*/
	@RequestMapping(value = "/Pig/{pig_id}/pigByThirdLikelyMaleParentId", method = RequestMethod.PUT)
	@ResponseBody
	public Pig savePigPigByThirdLikelyMaleParentId(@PathVariable Integer pig_id, @RequestBody Pig pigbythirdlikelymaleparentid) {
		pigService.savePigPigByThirdLikelyMaleParentId(pig_id, pigbythirdlikelymaleparentid);
		return pigDAO.findPigByPrimaryKey(pigbythirdlikelymaleparentid.getId());
	}

	/**
	* Show all SalePig entities by Pig
	* 
	*/
	@RequestMapping(value = "/Pig/{pig_id}/salePigs", method = RequestMethod.GET)
	@ResponseBody
	public List<SalePig> getPigSalePigs(@PathVariable Integer pig_id) {
		return new java.util.ArrayList<SalePig>(pigDAO.findPigByPrimaryKey(pig_id).getSalePigs());
	}

	/**
	* Create a new Transfer entity
	* 
	*/
	@RequestMapping(value = "/Pig/{pig_id}/transfers", method = RequestMethod.POST)
	@ResponseBody
	public Transfer newPigTransfers(@PathVariable Integer pig_id, @RequestBody Transfer transfer) {
		pigService.savePigTransfers(pig_id, transfer);
		return transferDAO.findTransferByPrimaryKey(transfer.getId());
	}

	/**
	* View an existing Pig entity
	* 
	*/
	@RequestMapping(value = "/Pig/{pig_id}/pigsForSecondLikelyMaleParentId/{pig_id}", method = RequestMethod.GET)
	@ResponseBody
	public Pig loadPigPigsForSecondLikelyMaleParentId(@PathVariable Integer pig_id, @PathVariable Integer related_pigsforsecondlikelymaleparentid_id) {
		Pig pig = pigDAO.findPigByPrimaryKey(related_pigsforsecondlikelymaleparentid_id, -1, -1);

		return pig;
	}

	/**
	* Create a new Pig entity
	* 
	*/
	@RequestMapping(value = "/Pig/{pig_id}/pigsForSecondLikelyMaleParentId", method = RequestMethod.POST)
	@ResponseBody
	public Pig newPigPigsForSecondLikelyMaleParentId(@PathVariable Integer pig_id, @RequestBody Pig pig) {
		pigService.savePigPigsForSecondLikelyMaleParentId(pig_id, pig);
		return pigDAO.findPigByPrimaryKey(pig.getId());
	}

	/**
	* Show all TaskPig entities by Pig
	* 
	*/
	@RequestMapping(value = "/Pig/{pig_id}/taskPigs", method = RequestMethod.GET)
	@ResponseBody
	public List<TaskPig> getPigTaskPigs(@PathVariable Integer pig_id) {
		return new java.util.ArrayList<TaskPig>(pigDAO.findPigByPrimaryKey(pig_id).getTaskPigs());
	}

	/**
	* Create a new Pig entity
	* 
	*/
	@RequestMapping(value = "/Pig/{pig_id}/pigByFemaleParentId", method = RequestMethod.POST)
	@ResponseBody
	public Pig newPigPigByFemaleParentId(@PathVariable Integer pig_id, @RequestBody Pig pig) {
		pigService.savePigPigByFemaleParentId(pig_id, pig);
		return pigDAO.findPigByPrimaryKey(pig.getId());
	}

	/**
	* Show all Pig entities by Pig
	* 
	*/
	@RequestMapping(value = "/Pig/{pig_id}/pigsForSecondLikelyMaleParentId", method = RequestMethod.GET)
	@ResponseBody
	public List<Pig> getPigPigsForSecondLikelyMaleParentId(@PathVariable Integer pig_id) {
		return new java.util.ArrayList<Pig>(pigDAO.findPigByPrimaryKey(pig_id).getPigsForSecondLikelyMaleParentId());
	}

	/**
	* Select an existing Pig entity
	* 
	*/
	@RequestMapping(value = "/Pig/{pig_id}", method = RequestMethod.GET)
	@ResponseBody
	public Pig loadPig(@PathVariable Integer pig_id) {
		return pigDAO.findPigByPrimaryKey(pig_id);
	}

	/**
	* Delete an existing Pig entity
	* 
	*/
	@RequestMapping(value = "/Pig/{pig_id}/pigByThirdLikelyMaleParentId/{pig_id}", method = RequestMethod.DELETE)
	@ResponseBody
	public void deletePigPigByThirdLikelyMaleParentId(@PathVariable Integer pig_id, @PathVariable Integer related_pigbythirdlikelymaleparentid_id) {
		pigService.deletePigPigByThirdLikelyMaleParentId(pig_id, related_pigbythirdlikelymaleparentid_id);
	}

	/**
	* View an existing SalePig entity
	* 
	*/
	@RequestMapping(value = "/Pig/{pig_id}/salePigs/{salepig_id}", method = RequestMethod.GET)
	@ResponseBody
	public SalePig loadPigSalePigs(@PathVariable Integer pig_id, @PathVariable Integer related_salepigs_id) {
		SalePig salepig = salePigDAO.findSalePigByPrimaryKey(related_salepigs_id, -1, -1);

		return salepig;
	}

	/**
	* Delete an existing Pig entity
	* 
	*/
	@RequestMapping(value = "/Pig/{pig_id}/pigByMostLikelyMaleParentId/{pig_id}", method = RequestMethod.DELETE)
	@ResponseBody
	public void deletePigPigByMostLikelyMaleParentId(@PathVariable Integer pig_id, @PathVariable Integer related_pigbymostlikelymaleparentid_id) {
		pigService.deletePigPigByMostLikelyMaleParentId(pig_id, related_pigbymostlikelymaleparentid_id);
	}

	/**
	* View an existing Pig entity
	* 
	*/
	@RequestMapping(value = "/Pig/{pig_id}/pigByFemaleParentId/{pig_id}", method = RequestMethod.GET)
	@ResponseBody
	public Pig loadPigPigByFemaleParentId(@PathVariable Integer pig_id, @PathVariable Integer related_pigbyfemaleparentid_id) {
		Pig pig = pigDAO.findPigByPrimaryKey(related_pigbyfemaleparentid_id, -1, -1);

		return pig;
	}

	/**
	* Show all PigWeight entities by Pig
	* 
	*/
	@RequestMapping(value = "/Pig/{pig_id}/pigWeights", method = RequestMethod.GET)
	@ResponseBody
	public List<PigWeight> getPigPigWeights(@PathVariable Integer pig_id) {
		return new java.util.ArrayList<PigWeight>(pigDAO.findPigByPrimaryKey(pig_id).getPigWeights());
	}

	/**
	* Save an existing Pig entity
	* 
	*/
	@RequestMapping(value = "/Pig/{pig_id}/pigsForMostLikelyMaleParentId", method = RequestMethod.PUT)
	@ResponseBody
	public Pig savePigPigsForMostLikelyMaleParentId(@PathVariable Integer pig_id, @RequestBody Pig pigsformostlikelymaleparentid) {
		pigService.savePigPigsForMostLikelyMaleParentId(pig_id, pigsformostlikelymaleparentid);
		return pigDAO.findPigByPrimaryKey(pigsformostlikelymaleparentid.getId());
	}

	/**
	* Get PigType entity by Pig
	* 
	*/
	@RequestMapping(value = "/Pig/{pig_id}/pigType", method = RequestMethod.GET)
	@ResponseBody
	public PigType getPigPigType(@PathVariable Integer pig_id) {
		return pigDAO.findPigByPrimaryKey(pig_id).getPigType();
	}

	/**
	* View an existing Pig entity
	* 
	*/
	@RequestMapping(value = "/Pig/{pig_id}/pigBySecondLikelyMaleParentId/{pig_id}", method = RequestMethod.GET)
	@ResponseBody
	public Pig loadPigPigBySecondLikelyMaleParentId(@PathVariable Integer pig_id, @PathVariable Integer related_pigbysecondlikelymaleparentid_id) {
		Pig pig = pigDAO.findPigByPrimaryKey(related_pigbysecondlikelymaleparentid_id, -1, -1);

		return pig;
	}

	/**
	* Create a new Pig entity
	* 
	*/
	@RequestMapping(value = "/Pig/{pig_id}/pigsForFemaleParentId", method = RequestMethod.POST)
	@ResponseBody
	public Pig newPigPigsForFemaleParentId(@PathVariable Integer pig_id, @RequestBody Pig pig) {
		pigService.savePigPigsForFemaleParentId(pig_id, pig);
		return pigDAO.findPigByPrimaryKey(pig.getId());
	}

	/**
	* Delete an existing PigType entity
	* 
	*/
	@RequestMapping(value = "/Pig/{pig_id}/pigType/{pigtype_id}", method = RequestMethod.DELETE)
	@ResponseBody
	public void deletePigPigType(@PathVariable Integer pig_id, @PathVariable Integer related_pigtype_id) {
		pigService.deletePigPigType(pig_id, related_pigtype_id);
	}

	/**
	* Save an existing Transfer entity
	* 
	*/
	@RequestMapping(value = "/Pig/{pig_id}/transfers", method = RequestMethod.PUT)
	@ResponseBody
	public Transfer savePigTransfers(@PathVariable Integer pig_id, @RequestBody Transfer transfers) {
		pigService.savePigTransfers(pig_id, transfers);
		return transferDAO.findTransferByPrimaryKey(transfers.getId());
	}

	/**
	* Delete an existing TaskPig entity
	* 
	*/
	@RequestMapping(value = "/Pig/{pig_id}/taskPigs/{taskpig_id}", method = RequestMethod.DELETE)
	@ResponseBody
	public void deletePigTaskPigs(@PathVariable Integer pig_id, @PathVariable Integer related_taskpigs_id) {
		pigService.deletePigTaskPigs(pig_id, related_taskpigs_id);
	}

	/**
	* Show all Pig entities
	* 
	*/
	@RequestMapping(value = "/Pig", method = RequestMethod.GET)
	@ResponseBody
	public List<Pig> listPigs() {
		return new java.util.ArrayList<Pig>(pigService.loadPigs());
	}

	/**
	* Delete an existing Pig entity
	* 
	*/
	@RequestMapping(value = "/Pig/{pig_id}/pigsForSecondLikelyMaleParentId/{pig_id}", method = RequestMethod.DELETE)
	@ResponseBody
	public void deletePigPigsForSecondLikelyMaleParentId(@PathVariable Integer pig_id, @PathVariable Integer related_pigsforsecondlikelymaleparentid_id) {
		pigService.deletePigPigsForSecondLikelyMaleParentId(pig_id, related_pigsforsecondlikelymaleparentid_id);
	}

	/**
	* Save an existing PigType entity
	* 
	*/
	@RequestMapping(value = "/Pig/{pig_id}/pigType", method = RequestMethod.PUT)
	@ResponseBody
	public PigType savePigPigType(@PathVariable Integer pig_id, @RequestBody PigType pigtype) {
		pigService.savePigPigType(pig_id, pigtype);
		return pigTypeDAO.findPigTypeByPrimaryKey(pigtype.getId());
	}

	/**
	* Save an existing Pig entity
	* 
	*/
	@RequestMapping(value = "/Pig/{pig_id}/pigsForFemaleParentId", method = RequestMethod.PUT)
	@ResponseBody
	public Pig savePigPigsForFemaleParentId(@PathVariable Integer pig_id, @RequestBody Pig pigsforfemaleparentid) {
		pigService.savePigPigsForFemaleParentId(pig_id, pigsforfemaleparentid);
		return pigDAO.findPigByPrimaryKey(pigsforfemaleparentid.getId());
	}

	/**
	* Create a new SalePig entity
	* 
	*/
	@RequestMapping(value = "/Pig/{pig_id}/salePigs", method = RequestMethod.POST)
	@ResponseBody
	public SalePig newPigSalePigs(@PathVariable Integer pig_id, @RequestBody SalePig salepig) {
		pigService.savePigSalePigs(pig_id, salepig);
		return salePigDAO.findSalePigByPrimaryKey(salepig.getId());
	}

	/**
	* Save an existing Pig entity
	* 
	*/
	@RequestMapping(value = "/Pig/{pig_id}/pigByFemaleParentId", method = RequestMethod.PUT)
	@ResponseBody
	public Pig savePigPigByFemaleParentId(@PathVariable Integer pig_id, @RequestBody Pig pigbyfemaleparentid) {
		pigService.savePigPigByFemaleParentId(pig_id, pigbyfemaleparentid);
		return pigDAO.findPigByPrimaryKey(pigbyfemaleparentid.getId());
	}

	/**
	* Save an existing Pig entity
	* 
	*/
	@RequestMapping(value = "/Pig", method = RequestMethod.PUT)
	@ResponseBody
	public Pig savePig(@RequestBody Pig pig) {
		pigService.savePig(pig);
		return pigDAO.findPigByPrimaryKey(pig.getId());
	}

	/**
	* Save an existing CurePig entity
	* 
	*/
	@RequestMapping(value = "/Pig/{pig_id}/curePigs", method = RequestMethod.PUT)
	@ResponseBody
	public CurePig savePigCurePigs(@PathVariable Integer pig_id, @RequestBody CurePig curepigs) {
		pigService.savePigCurePigs(pig_id, curepigs);
		return curePigDAO.findCurePigByPrimaryKey(curepigs.getId());
	}

	/**
	* Get Pig entity by Pig
	* 
	*/
	@RequestMapping(value = "/Pig/{pig_id}/pigBySecondLikelyMaleParentId", method = RequestMethod.GET)
	@ResponseBody
	public Pig getPigPigBySecondLikelyMaleParentId(@PathVariable Integer pig_id) {
		return pigDAO.findPigByPrimaryKey(pig_id).getPigBySecondLikelyMaleParentId();
	}

	/**
	* Create a new Pig entity
	* 
	*/
	@RequestMapping(value = "/Pig", method = RequestMethod.POST)
	@ResponseBody
	public Pig newPig(@RequestBody Pig pig) {
		pigService.savePig(pig);
		return pigDAO.findPigByPrimaryKey(pig.getId());
	}

	/**
	* View an existing PigType entity
	* 
	*/
	@RequestMapping(value = "/Pig/{pig_id}/pigType/{pigtype_id}", method = RequestMethod.GET)
	@ResponseBody
	public PigType loadPigPigType(@PathVariable Integer pig_id, @PathVariable Integer related_pigtype_id) {
		PigType pigtype = pigTypeDAO.findPigTypeByPrimaryKey(related_pigtype_id, -1, -1);

		return pigtype;
	}

	/**
	* Create a new Pig entity
	* 
	*/
	@RequestMapping(value = "/Pig/{pig_id}/pigByMostLikelyMaleParentId", method = RequestMethod.POST)
	@ResponseBody
	public Pig newPigPigByMostLikelyMaleParentId(@PathVariable Integer pig_id, @RequestBody Pig pig) {
		pigService.savePigPigByMostLikelyMaleParentId(pig_id, pig);
		return pigDAO.findPigByPrimaryKey(pig.getId());
	}

	/**
	* Save an existing Pig entity
	* 
	*/
	@RequestMapping(value = "/Pig/{pig_id}/pigsForSecondLikelyMaleParentId", method = RequestMethod.PUT)
	@ResponseBody
	public Pig savePigPigsForSecondLikelyMaleParentId(@PathVariable Integer pig_id, @RequestBody Pig pigsforsecondlikelymaleparentid) {
		pigService.savePigPigsForSecondLikelyMaleParentId(pig_id, pigsforsecondlikelymaleparentid);
		return pigDAO.findPigByPrimaryKey(pigsforsecondlikelymaleparentid.getId());
	}

	/**
	* View an existing Transfer entity
	* 
	*/
	@RequestMapping(value = "/Pig/{pig_id}/transfers/{transfer_id}", method = RequestMethod.GET)
	@ResponseBody
	public Transfer loadPigTransfers(@PathVariable Integer pig_id, @PathVariable Integer related_transfers_id) {
		Transfer transfer = transferDAO.findTransferByPrimaryKey(related_transfers_id, -1, -1);

		return transfer;
	}

	/**
	* Delete an existing Pig entity
	* 
	*/
	@RequestMapping(value = "/Pig/{pig_id}/pigByFemaleParentId/{pig_id}", method = RequestMethod.DELETE)
	@ResponseBody
	public void deletePigPigByFemaleParentId(@PathVariable Integer pig_id, @PathVariable Integer related_pigbyfemaleparentid_id) {
		pigService.deletePigPigByFemaleParentId(pig_id, related_pigbyfemaleparentid_id);
	}

	/**
	* Save an existing Pig entity
	* 
	*/
	@RequestMapping(value = "/Pig/{pig_id}/pigByMostLikelyMaleParentId", method = RequestMethod.PUT)
	@ResponseBody
	public Pig savePigPigByMostLikelyMaleParentId(@PathVariable Integer pig_id, @RequestBody Pig pigbymostlikelymaleparentid) {
		pigService.savePigPigByMostLikelyMaleParentId(pig_id, pigbymostlikelymaleparentid);
		return pigDAO.findPigByPrimaryKey(pigbymostlikelymaleparentid.getId());
	}

	/**
	* View an existing Pig entity
	* 
	*/
	@RequestMapping(value = "/Pig/{pig_id}/pigsForThirdLikelyMaleParentId/{pig_id}", method = RequestMethod.GET)
	@ResponseBody
	public Pig loadPigPigsForThirdLikelyMaleParentId(@PathVariable Integer pig_id, @PathVariable Integer related_pigsforthirdlikelymaleparentid_id) {
		Pig pig = pigDAO.findPigByPrimaryKey(related_pigsforthirdlikelymaleparentid_id, -1, -1);

		return pig;
	}

	/**
	* View an existing CurePig entity
	* 
	*/
	@RequestMapping(value = "/Pig/{pig_id}/curePigs/{curepig_id}", method = RequestMethod.GET)
	@ResponseBody
	public CurePig loadPigCurePigs(@PathVariable Integer pig_id, @PathVariable Integer related_curepigs_id) {
		CurePig curepig = curePigDAO.findCurePigByPrimaryKey(related_curepigs_id, -1, -1);

		return curepig;
	}

	/**
	* Create a new Pig entity
	* 
	*/
	@RequestMapping(value = "/Pig/{pig_id}/pigByThirdLikelyMaleParentId", method = RequestMethod.POST)
	@ResponseBody
	public Pig newPigPigByThirdLikelyMaleParentId(@PathVariable Integer pig_id, @RequestBody Pig pig) {
		pigService.savePigPigByThirdLikelyMaleParentId(pig_id, pig);
		return pigDAO.findPigByPrimaryKey(pig.getId());
	}

	/**
	* Save an existing Pig entity
	* 
	*/
	@RequestMapping(value = "/Pig/{pig_id}/pigsForThirdLikelyMaleParentId", method = RequestMethod.PUT)
	@ResponseBody
	public Pig savePigPigsForThirdLikelyMaleParentId(@PathVariable Integer pig_id, @RequestBody Pig pigsforthirdlikelymaleparentid) {
		pigService.savePigPigsForThirdLikelyMaleParentId(pig_id, pigsforthirdlikelymaleparentid);
		return pigDAO.findPigByPrimaryKey(pigsforthirdlikelymaleparentid.getId());
	}

	/**
	* Save an existing Pig entity
	* 
	*/
	@RequestMapping(value = "/Pig/{pig_id}/pigBySecondLikelyMaleParentId", method = RequestMethod.PUT)
	@ResponseBody
	public Pig savePigPigBySecondLikelyMaleParentId(@PathVariable Integer pig_id, @RequestBody Pig pigbysecondlikelymaleparentid) {
		pigService.savePigPigBySecondLikelyMaleParentId(pig_id, pigbysecondlikelymaleparentid);
		return pigDAO.findPigByPrimaryKey(pigbysecondlikelymaleparentid.getId());
	}

	/**
	* Create a new Pig entity
	* 
	*/
	@RequestMapping(value = "/Pig/{pig_id}/pigsForThirdLikelyMaleParentId", method = RequestMethod.POST)
	@ResponseBody
	public Pig newPigPigsForThirdLikelyMaleParentId(@PathVariable Integer pig_id, @RequestBody Pig pig) {
		pigService.savePigPigsForThirdLikelyMaleParentId(pig_id, pig);
		return pigDAO.findPigByPrimaryKey(pig.getId());
	}

	/**
	* Delete an existing Pig entity
	* 
	*/
	@RequestMapping(value = "/Pig/{pig_id}/pigsForThirdLikelyMaleParentId/{pig_id}", method = RequestMethod.DELETE)
	@ResponseBody
	public void deletePigPigsForThirdLikelyMaleParentId(@PathVariable Integer pig_id, @PathVariable Integer related_pigsforthirdlikelymaleparentid_id) {
		pigService.deletePigPigsForThirdLikelyMaleParentId(pig_id, related_pigsforthirdlikelymaleparentid_id);
	}

	/**
	* Show all Pig entities by Pig
	* 
	*/
	@RequestMapping(value = "/Pig/{pig_id}/pigsForThirdLikelyMaleParentId", method = RequestMethod.GET)
	@ResponseBody
	public List<Pig> getPigPigsForThirdLikelyMaleParentId(@PathVariable Integer pig_id) {
		return new java.util.ArrayList<Pig>(pigDAO.findPigByPrimaryKey(pig_id).getPigsForThirdLikelyMaleParentId());
	}

	/**
	* View an existing PigWeight entity
	* 
	*/
	@RequestMapping(value = "/Pig/{pig_id}/pigWeights/{pigweight_id}", method = RequestMethod.GET)
	@ResponseBody
	public PigWeight loadPigPigWeights(@PathVariable Integer pig_id, @PathVariable Integer related_pigweights_id) {
		PigWeight pigweight = pigWeightDAO.findPigWeightByPrimaryKey(related_pigweights_id, -1, -1);

		return pigweight;
	}

	/**
	* Delete an existing SalePig entity
	* 
	*/
	@RequestMapping(value = "/Pig/{pig_id}/salePigs/{salepig_id}", method = RequestMethod.DELETE)
	@ResponseBody
	public void deletePigSalePigs(@PathVariable Integer pig_id, @PathVariable Integer related_salepigs_id) {
		pigService.deletePigSalePigs(pig_id, related_salepigs_id);
	}

	/**
	* Get Pig entity by Pig
	* 
	*/
	@RequestMapping(value = "/Pig/{pig_id}/pigByFemaleParentId", method = RequestMethod.GET)
	@ResponseBody
	public Pig getPigPigByFemaleParentId(@PathVariable Integer pig_id) {
		return pigDAO.findPigByPrimaryKey(pig_id).getPigByFemaleParentId();
	}

	/**
	* Show all Pig entities by Pig
	* 
	*/
	@RequestMapping(value = "/Pig/{pig_id}/pigsForFemaleParentId", method = RequestMethod.GET)
	@ResponseBody
	public List<Pig> getPigPigsForFemaleParentId(@PathVariable Integer pig_id) {
		return new java.util.ArrayList<Pig>(pigDAO.findPigByPrimaryKey(pig_id).getPigsForFemaleParentId());
	}

	/**
	* View an existing Pig entity
	* 
	*/
	@RequestMapping(value = "/Pig/{pig_id}/pigByMostLikelyMaleParentId/{pig_id}", method = RequestMethod.GET)
	@ResponseBody
	public Pig loadPigPigByMostLikelyMaleParentId(@PathVariable Integer pig_id, @PathVariable Integer related_pigbymostlikelymaleparentid_id) {
		Pig pig = pigDAO.findPigByPrimaryKey(related_pigbymostlikelymaleparentid_id, -1, -1);

		return pig;
	}

	/**
	* Save an existing PigWeight entity
	* 
	*/
	@RequestMapping(value = "/Pig/{pig_id}/pigWeights", method = RequestMethod.PUT)
	@ResponseBody
	public PigWeight savePigPigWeights(@PathVariable Integer pig_id, @RequestBody PigWeight pigweights) {
		pigService.savePigPigWeights(pig_id, pigweights);
		return pigWeightDAO.findPigWeightByPrimaryKey(pigweights.getId());
	}

	/**
	* Create a new PigWeight entity
	* 
	*/
	@RequestMapping(value = "/Pig/{pig_id}/pigWeights", method = RequestMethod.POST)
	@ResponseBody
	public PigWeight newPigPigWeights(@PathVariable Integer pig_id, @RequestBody PigWeight pigweight) {
		pigService.savePigPigWeights(pig_id, pigweight);
		return pigWeightDAO.findPigWeightByPrimaryKey(pigweight.getId());
	}

	/**
	* Save an existing TaskPig entity
	* 
	*/
	@RequestMapping(value = "/Pig/{pig_id}/taskPigs", method = RequestMethod.PUT)
	@ResponseBody
	public TaskPig savePigTaskPigs(@PathVariable Integer pig_id, @RequestBody TaskPig taskpigs) {
		pigService.savePigTaskPigs(pig_id, taskpigs);
		return taskPigDAO.findTaskPigByPrimaryKey(taskpigs.getId());
	}

	/**
	* Delete an existing Pig entity
	* 
	*/
	@RequestMapping(value = "/Pig/{pig_id}/pigBySecondLikelyMaleParentId/{pig_id}", method = RequestMethod.DELETE)
	@ResponseBody
	public void deletePigPigBySecondLikelyMaleParentId(@PathVariable Integer pig_id, @PathVariable Integer related_pigbysecondlikelymaleparentid_id) {
		pigService.deletePigPigBySecondLikelyMaleParentId(pig_id, related_pigbysecondlikelymaleparentid_id);
	}

	/**
	* Delete an existing Pig entity
	* 
	*/
	@RequestMapping(value = "/Pig/{pig_id}/pigsForMostLikelyMaleParentId/{pig_id}", method = RequestMethod.DELETE)
	@ResponseBody
	public void deletePigPigsForMostLikelyMaleParentId(@PathVariable Integer pig_id, @PathVariable Integer related_pigsformostlikelymaleparentid_id) {
		pigService.deletePigPigsForMostLikelyMaleParentId(pig_id, related_pigsformostlikelymaleparentid_id);
	}

	/**
	* View an existing Pig entity
	* 
	*/
	@RequestMapping(value = "/Pig/{pig_id}/pigByThirdLikelyMaleParentId/{pig_id}", method = RequestMethod.GET)
	@ResponseBody
	public Pig loadPigPigByThirdLikelyMaleParentId(@PathVariable Integer pig_id, @PathVariable Integer related_pigbythirdlikelymaleparentid_id) {
		Pig pig = pigDAO.findPigByPrimaryKey(related_pigbythirdlikelymaleparentid_id, -1, -1);

		return pig;
	}

	/**
	* Get Pig entity by Pig
	* 
	*/
	@RequestMapping(value = "/Pig/{pig_id}/pigByThirdLikelyMaleParentId", method = RequestMethod.GET)
	@ResponseBody
	public Pig getPigPigByThirdLikelyMaleParentId(@PathVariable Integer pig_id) {
		return pigDAO.findPigByPrimaryKey(pig_id).getPigByThirdLikelyMaleParentId();
	}

	/**
	* Show all CurePig entities by Pig
	* 
	*/
	@RequestMapping(value = "/Pig/{pig_id}/curePigs", method = RequestMethod.GET)
	@ResponseBody
	public List<CurePig> getPigCurePigs(@PathVariable Integer pig_id) {
		return new java.util.ArrayList<CurePig>(pigDAO.findPigByPrimaryKey(pig_id).getCurePigs());
	}

	/**
	* Register custom, context-specific property editors
	* 
	*/
	@InitBinder
	public void initBinder(WebDataBinder binder, HttpServletRequest request) { // Register static property editors.
		binder.registerCustomEditor(java.util.Calendar.class, new org.skyway.spring.util.databinding.CustomCalendarEditor());
		binder.registerCustomEditor(byte[].class, new org.springframework.web.multipart.support.ByteArrayMultipartFileEditor());
		binder.registerCustomEditor(boolean.class, new org.skyway.spring.util.databinding.EnhancedBooleanEditor(false));
		binder.registerCustomEditor(Boolean.class, new org.skyway.spring.util.databinding.EnhancedBooleanEditor(true));
		binder.registerCustomEditor(java.math.BigDecimal.class, new org.skyway.spring.util.databinding.NaNHandlingNumberEditor(java.math.BigDecimal.class, true));
		binder.registerCustomEditor(Integer.class, new org.skyway.spring.util.databinding.NaNHandlingNumberEditor(Integer.class, true));
		binder.registerCustomEditor(java.util.Date.class, new org.skyway.spring.util.databinding.CustomDateEditor());
		binder.registerCustomEditor(String.class, new org.skyway.spring.util.databinding.StringEditor());
		binder.registerCustomEditor(Long.class, new org.skyway.spring.util.databinding.NaNHandlingNumberEditor(Long.class, true));
		binder.registerCustomEditor(Double.class, new org.skyway.spring.util.databinding.NaNHandlingNumberEditor(Double.class, true));
	}

	/**
	* Create a new Pig entity
	* 
	*/
	@RequestMapping(value = "/Pig/{pig_id}/pigBySecondLikelyMaleParentId", method = RequestMethod.POST)
	@ResponseBody
	public Pig newPigPigBySecondLikelyMaleParentId(@PathVariable Integer pig_id, @RequestBody Pig pig) {
		pigService.savePigPigBySecondLikelyMaleParentId(pig_id, pig);
		return pigDAO.findPigByPrimaryKey(pig.getId());
	}

	/**
	* View an existing Pig entity
	* 
	*/
	@RequestMapping(value = "/Pig/{pig_id}/pigsForMostLikelyMaleParentId/{pig_id}", method = RequestMethod.GET)
	@ResponseBody
	public Pig loadPigPigsForMostLikelyMaleParentId(@PathVariable Integer pig_id, @PathVariable Integer related_pigsformostlikelymaleparentid_id) {
		Pig pig = pigDAO.findPigByPrimaryKey(related_pigsformostlikelymaleparentid_id, -1, -1);

		return pig;
	}

	/**
	* Create a new PigType entity
	* 
	*/
	@RequestMapping(value = "/Pig/{pig_id}/pigType", method = RequestMethod.POST)
	@ResponseBody
	public PigType newPigPigType(@PathVariable Integer pig_id, @RequestBody PigType pigtype) {
		pigService.savePigPigType(pig_id, pigtype);
		return pigTypeDAO.findPigTypeByPrimaryKey(pigtype.getId());
	}

	/**
	* Get Pig entity by Pig
	* 
	*/
	@RequestMapping(value = "/Pig/{pig_id}/pigByMostLikelyMaleParentId", method = RequestMethod.GET)
	@ResponseBody
	public Pig getPigPigByMostLikelyMaleParentId(@PathVariable Integer pig_id) {
		return pigDAO.findPigByPrimaryKey(pig_id).getPigByMostLikelyMaleParentId();
	}

	/**
	* Delete an existing Pig entity
	* 
	*/
	@RequestMapping(value = "/Pig/{pig_id}/pigsForFemaleParentId/{pig_id}", method = RequestMethod.DELETE)
	@ResponseBody
	public void deletePigPigsForFemaleParentId(@PathVariable Integer pig_id, @PathVariable Integer related_pigsforfemaleparentid_id) {
		pigService.deletePigPigsForFemaleParentId(pig_id, related_pigsforfemaleparentid_id);
	}

	/**
	* Delete an existing Pig entity
	* 
	*/
	@RequestMapping(value = "/Pig/{pig_id}", method = RequestMethod.DELETE)
	@ResponseBody
	public void deletePig(@PathVariable Integer pig_id) {
		Pig pig = pigDAO.findPigByPrimaryKey(pig_id);
		pigService.deletePig(pig);
	}

	/**
	* View an existing TaskPig entity
	* 
	*/
	@RequestMapping(value = "/Pig/{pig_id}/taskPigs/{taskpig_id}", method = RequestMethod.GET)
	@ResponseBody
	public TaskPig loadPigTaskPigs(@PathVariable Integer pig_id, @PathVariable Integer related_taskpigs_id) {
		TaskPig taskpig = taskPigDAO.findTaskPigByPrimaryKey(related_taskpigs_id, -1, -1);

		return taskpig;
	}

	/**
	* Show all Transfer entities by Pig
	* 
	*/
	@RequestMapping(value = "/Pig/{pig_id}/transfers", method = RequestMethod.GET)
	@ResponseBody
	public List<Transfer> getPigTransfers(@PathVariable Integer pig_id) {
		return new java.util.ArrayList<Transfer>(pigDAO.findPigByPrimaryKey(pig_id).getTransfers());
	}

	/**
	* View an existing Pig entity
	* 
	*/
	@RequestMapping(value = "/Pig/{pig_id}/pigsForFemaleParentId/{pig_id}", method = RequestMethod.GET)
	@ResponseBody
	public Pig loadPigPigsForFemaleParentId(@PathVariable Integer pig_id, @PathVariable Integer related_pigsforfemaleparentid_id) {
		Pig pig = pigDAO.findPigByPrimaryKey(related_pigsforfemaleparentid_id, -1, -1);

		return pig;
	}

	/**
	* Create a new TaskPig entity
	* 
	*/
	@RequestMapping(value = "/Pig/{pig_id}/taskPigs", method = RequestMethod.POST)
	@ResponseBody
	public TaskPig newPigTaskPigs(@PathVariable Integer pig_id, @RequestBody TaskPig taskpig) {
		pigService.savePigTaskPigs(pig_id, taskpig);
		return taskPigDAO.findTaskPigByPrimaryKey(taskpig.getId());
	}

	/**
	* Save an existing SalePig entity
	* 
	*/
	@RequestMapping(value = "/Pig/{pig_id}/salePigs", method = RequestMethod.PUT)
	@ResponseBody
	public SalePig savePigSalePigs(@PathVariable Integer pig_id, @RequestBody SalePig salepigs) {
		pigService.savePigSalePigs(pig_id, salepigs);
		return salePigDAO.findSalePigByPrimaryKey(salepigs.getId());
	}
}